
//
//  OALawRuleVC.m
//  OA项目
//
//  Created by innofive on 2018/5/11.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OALawRuleVC.h"
#import "OAWebVC.h"
@interface OALawRuleVC ()

@end

@implementation OALawRuleVC

- (void)viewDidLoad {
    [super viewDidLoad];
   
    NSArray *arr= @[@{@"title":@"q啊舒服舒服啊舒服舒服啊舒服舒服啊舒服舒服",@"timer":@"2016-05-03",@"detail":@"创建人:市场王剑波"},
                    @{@"title":@"q啊舒服啊舒服舒服啊舒服舒服舒服",@"timer":@"2016-05-03",@"detail":@"创建人:市场王剑波"},
                    @{@"title":@"q啊舒服啊舒服舒服舒服",@"timer":@"2016-05-03",@"detail":@"创建人:市场王剑波"},
                    @{@"title":@"q啊舒服舒啊舒服舒服啊舒服舒服啊舒服舒服啊舒服舒服啊舒服舒服服",@"timer":@"2016-05-03",@"detail":@"创建人:市场王剑波"},
                    @{@"title":@"q啊啊舒服舒服啊舒服舒服啊舒服舒服啊舒服舒服舒服舒服",@"timer":@"2016-05-03",@"detail":@"创建人:市场王剑波"},];
    [self.dataArr addObjectsFromArray:arr];
    
    
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    [self.tableView config:^(UITableView *tableView) {
        [tableView setSeparatorMan];
    }];
}

#pragma mark - 点击方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    

    OAWebVC *vc =[OAWebVC new];
    vc.title = @"法律法规";
    vc.url = @"http://wwww.baidu.com";
    [self pushToVC:vc];
    
}

#pragma mark - Table view data source
-(void)onSetSubviewSELForCell:(BaseTableViewCell *)cell forTableView:(UITableView *)tableView forIndexPath:(NSIndexPath *)indexPath
{
    cell.textLabel.textColor = [UIColor blackColor];
    cell.textLabel.font = kSysFont(kFitW(15));
    cell.textLabel.numberOfLines = 0;
    
    
    UILabel *timer = ({
        UILabel *l = [UILabel new];
        l.textColor = [UIColor blackColor];
        l.font = kSysFont(kFitW(13));
        l.tag = 10;
        [cell.contentView addV:l];
        l;
    });
    
    cell.detailTextLabel.textColor = [UIColor blackColor];
    cell.detailTextLabel.font = kSysFont(kFitW(13));
    cell.detailTextLabel.numberOfLines = 0;
    
    [cell onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        [cell.textLabel sizeToFit];
        
        cell.textLabel.left = kFitW(10);
        cell.textLabel.top = kFitH(7.5);
        
        [timer sizeToFit];
        timer.left =cell.textLabel.left;
        timer.top =cell.textLabel.bottom+kFitH(5);
        
        [cell.detailTextLabel sizeToFit];
        cell.detailTextLabel.left = kFitW(10);
        cell.detailTextLabel.top = timer.bottom+kFitH(5);
        
    }];
    
}
-(void)onUpdateCell:(BaseTableViewCell *)cell model:(NSDictionary *)model atIndexPath:(NSIndexPath *)indexPath
{
    cell.textLabel.text = model[@"title"];
    cell.detailTextLabel.text = model[@"detail"];
    UILabel *timer = [(id)cell.contentView viewWithTag:10];
    timer.text = model[@"timer"];
}
-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    WSELF(weakSelf);
//    return [MCCellInfo configForCellId:cell Class:[BaseTableViewCell class] Height:150 TableView:tableView CellStyle:UITableViewCellStyleSubtitle];
    return [MCCellInfo configForCellId:cell Class:[BaseTableViewCell class]UpdateHeight:^CGFloat(NSString *cellId, UITableView *tableView, NSIndexPath *indexPath) {
        NSDictionary *dic = [weakSelf modelForIndexPath:indexPath];
        NSString *title = dic[@"title"];
        NSString *title1 = dic[@"timer"];
        NSString *title2 = dic[@"detail"];

        CGFloat w = kScreenW-kFitW(10);
        CGFloat h = [NSString calculateLabelHeight:title font:kSysFont(kFitW(15)) AndWidth:w];
        CGFloat h1 = [NSString calculateLabelHeight:title1 font:kSysFont(kFitW(13)) AndWidth:w];
        CGFloat h2 = [NSString calculateLabelHeight:title2 font:kSysFont(kFitW(13)) AndWidth:w];
        return h+h1+h2+kFitH(7.5+5+15);
    } TableView:tableView forIndexPath:indexPath CellStyle:UITableViewCellStyleSubtitle IsBian:isheight];
}

@end
